package org.fenixsoft.jvm.chapter8.my;

/**
 * 方法静态分派演示
 * @author zzm
 */
public class StaticDispatch2 {

    static  class Human {
        void sayHello(){
            System.out.println("hello,guy!");
        };
    }

    static class Man extends Human {
        @Override
        void sayHello() {
            System.out.println("hello,gentleman!");
        }
    }

    static class Woman extends Human {
        @Override
        void sayHello() {
            System.out.println("hello,lady!");
        }
    }

    public void sayHello(Human guy) {
        guy.sayHello();
    }

    public static void main(String[] args) {
        Human man = new Man();
        Human woman = new Woman();
        StaticDispatch2 sr = new StaticDispatch2();
        sr.sayHello(man);
        sr.sayHello(woman);
    }
}
